/*
 * WorkerGrid.h
 *
 *  Created on: Jul 16, 2012
 *      Author: luporini
 */

#ifndef WORKERGRID_H_
#define WORKERGRID_H_

#include "Module.h"
#include "Common.h"
#include "Worker.h"

template <class T, class K >
class WorkerGrid {
private:
	Worker<T, K>**  workers;
	int 			rows, cols;
	int				countRows, countCols; //counter for rows and cols

public:
	inline WorkerGrid ( int _rows, int _cols )
	{
		rows = WINDOW / _rows;
		cols = WINDOW / _cols;
		countRows = 0;
		countCols = 0;
	}

	inline ~WorkerGrid () {}

	int	initGrid ()
	{
		return 0;
	}

	int scatterRow ( T* block, int size )
	{
		int nDest = size / rows; // number of workers will receive the scatter

		for ( int i = 0; i < nDest; i++ )
		{
			workers[countRows++][0].rowQueue->push (block);

		}

		return 0;
	}

	int scatterCol ( T* block, int size )
	{
		int nDest = size / cols; // number of workers will receive the scatter

		return 0;
	}


};

#endif /* WORKERGRID_H_ */
